package com.cug.nageoffer.common.controller;


import com.cug.nageoffer.common.service.CategoryService;
import com.cug.nageoffer.model.entity.Category;
import com.cug.nageoffer.model.vo.Result;
import com.cug.nageoffer.model.vo.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "前台首页相关")
@RestController
@RequestMapping(value = "/api/index")
@Slf4j
public class IndexController {

    @Autowired
    private CategoryService categoryService;

    @Operation(summary = "查询分类数据")
    @GetMapping(value = "/getCategory/{parentId}")
    public Result<List<Category>> getCategory(@PathVariable Long parentId){
        log.info("查询分类数据，parentID：{}", parentId);
        List<Category> list = categoryService.getCategory(parentId);
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }





}
